########################################################################
# PLACE LIST CREATIONS HERE #
########################################################################
stage_list = ["moon", "mars", "jupiter", "pluto", "space", "city"]
head_list = ["head1", "head2", "head3", "head4", "head5", "head6"]
########################################################################
# PLACE ALL OTHER CODE BELOW THIS #
########################################################################
stage_image = stage_list[1]
stage.set_background(stage_image)
random_head = random.randint(0, 5)
t = codesters.Teacher()
try:
tval1 = t.find_text('head_image')[0][1].replace(' ' , '')
except:
tval1 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 'head_image=head_list[random_head]', "Great job!")
t1.add_failure(tval1 == "DNE", "Did you use Get Value at Index and name the variable head_image?")
t1.add_failure('my_list' in tval1, "Oops! Did you change the list name to head_list?")
t1.add_failure('[random_head]' not in tval1, "Make sure you're accessing a random index in your list by putting random_head in the brackets.")
t1.add_failure('random_head' in tval1 and '[random_head]' not in tval1, "Oops! Make sure you don't delete the brackets around random_head!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)